﻿@using EasySite.Web

<div id="navigator">
    <div class="nav-wrap">
        @foreach (var item in EasySiteContext.Current.MenuCache.MenuItems) {
            if (item.Visible) {
                <div class='menu @(item.IsSelected?"selected":"")'>
                    <a href="@item.ActualHref" class="nav-main">@item.DisplayText</a>
                    @if (item.Children.Any(m=>m.Visible)) { 
                        <div class="submenu-container">
                            @foreach (var subItem in item.Children) { 
                                if(subItem.Visible) {
                                    <div class='submenu @(subItem.IsSelected?"selected":"")'>
                                        <a href="@subItem.ActualHref">@subItem.DisplayText</a>
                                    </div>
                                }
                            }
                            <div class="clear"></div>
                        </div>
                    }
                </div>
            } 
        }
        <div class="clear"></div>
    </div>
</div>
<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        $(".menu").mouseover(function () {
            $(this).find(".submenu-container").show();
        });
        $(".menu").mouseout(function () {
            $(this).find(".submenu-container").hide();
        });
        $(".submenu-container").mouseover(function () {
            $(this).show();
        });
        $(".submenu").click(function () {
            $(".submenu-container").hide();
        });
    });
</script>